//
//  LZLSettingViewController.swift
//  swiftDemo
//
//  Created by luozhilin on 2018/9/18.
//  Copyright © 2018年 luozhilin. All rights reserved.
//

import UIKit

class LZLSettingViewController: UIViewController {

    private lazy var titleArray = [["智能硬件"],
                                   ["特色闹铃","定时关闭"],
                                   ["账号与安全"],["推送设置","收听偏好设置","隐私设置"],
                                   ["断点续听","2G/3G/4G播放下载","下载音质","清理占用空间"],
                                   ["特色功能","新版本介绍","评价"],
                                   ["关于"]]
    
    
    private lazy var tableView:UITableView = {
        let tableView = UITableView()
        tableView.register(UITableViewCell.self,forCellReuseIdentifier:"cell")
        tableView.delegate = self
        tableView.dataSource = self
        tableView.rowHeight = 44
        return tableView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "设置"
        self.view.addSubview(self.tableView)
        self.tableView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }

    
}

extension LZLSettingViewController:UITableViewDelegate,UITableViewDataSource{
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return self.titleArray.count;
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.titleArray[section].count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell:UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
        cell.textLabel?.text = self.titleArray[indexPath.section][indexPath.row]
        if indexPath.section == 3 && indexPath.row == 1{
            let cellSwitch = UISwitch.init()
            cell.accessoryView = cellSwitch
        }else {
            cell.accessoryType = .disclosureIndicator
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let view = UIView(frame: CGRect(x: 0, y: 0, width: YYScreenWidth, height: 10))
        view.backgroundColor = FooterViewColor
        return view
    }
}
